{% extends "blog/base.html" %}
{% block title %}Share a post{% endblock %}
{% block content %}
<!-- 如果已经发送分享邮件，只显示分享成功信息 -->
{% if sent %}
<h1>E-mail successfully sent</h1>
<p>
"{{ post.title }}" was successfully sent to {{ form.cleaned_data.to}}.
</p>
<!-- 若尚未发送分享邮件，创建并渲染文章分享表单-->
{% else %}
<h1>Share "{{ post.title }}" by e-mail</h1>
<!-- 创建文章分享表单，数据提交请求类型为POST -->
<form method="post">
<!-- 快速根据视图提供的form表单渲染表单字段 -->
{{ form.as_p }}
<!-- 生成token防止跨站访问劫持 -->
{% csrf_token %}
<!-- 发送邮件按钮 -->
<input type="submit" value="Send e-mail">
</form>
{% endif %}
{% endblock %}